package com.qhit.service.impl;

import com.qhit.mapper.PermissionMapper;
import com.qhit.pojo.Permission;
import com.qhit.pojo.Role;
import com.qhit.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {
    @Autowired
    private PermissionMapper permissionMapper;


    public List<Permission> getList(HashMap hashMap) {
        return permissionMapper.getList(hashMap);
    }

    public int getListCount(HashMap hashMap) {
        return permissionMapper.getListCount(hashMap);
    }

    public int add(Permission permission) {
        return permissionMapper.add(permission);
    }

    public Permission getPermissionById(int id) {
        return permissionMapper.getPermissionById(id);
    }

    public int edit(Permission g) {
        return permissionMapper.edit(g);
    }

    @Transactional(rollbackFor = Exception.class)
    public int del(int id) {
        permissionMapper.delRoleByPermission(id);
            return permissionMapper.del(id);


    }


    public List<Permission> getPermissionsByRoleId(int id) {
        return permissionMapper.getPermissionsByRoleId(id);
    }
}
